package org.example.sy5.controller;

import org.example.sy5.entity.CustEntity;
import org.example.sy5.service.CustService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/cust")
public class CustController {
    @Autowired
    private CustService custService;
    @GetMapping("/getall")
    public List<CustEntity> getAll(){
        List<CustEntity> all = custService.getAll();
        return all;
    }
    @PostMapping("/add")
    public void add(@RequestBody CustEntity custEntity){
        custService.add(custEntity);
    }
    @PostMapping("/del")
    public void del(@RequestParam("id") int id){
        custService.del(id);
    }
    @PostMapping("/upd")
    public void upd(@RequestBody CustEntity custEntity){
        custService.upd(custEntity);
    }
}
